<?php
/*
 * 1626cms 職位比較
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
 */
define('IN_QISHI', true);
$page_select="jobs-search";
require_once('./include/common.inc.php');
//保存到cookie
if($_GET['act']=='setCompare'){
	$jobid=intval($_GET['jobid']);
	if($_SESSION['hkjob'] && array_key_exists($jobid, $_SESSION['hkjob']))die('該職位已經存在');
	if(count($_SESSION['hkjob'])>=3)die('一次最多只能比較三個職位');
	else{
		$jobtitle=trim($_GET['jobtitle']);
		$jobarray=array('jobid'=>$jobid,'jobtitle'=>$jobtitle);
		foreach ($jobarray as $key=>$value)
		{
			$_SESSION['hkjob'][$jobid][$key]=$value;
		}
	}
	exit;
}
if($_GET['act']=='getCompare')
{
	$jobarr=$_SESSION['hkjob'];
	print_r($jobarr);
	exit;
}
if($_GET['act']=='clearCompare')
{
	unset($_SESSION['hkjob']);
	exit;
}
if($_GET['act']=='reduceCompare')
{
	$jobid=intval($_GET['jobid']);
	unset($_SESSION["hkjob"][$jobid]);
	exit;
}
if($_GET['act']=='doCompare')
{

	$smarty->caching = false;
	require_once(QISHI_ROOT_PATH.'include/mysql.class.php');
	$db = new mysql($dbhost,$dbuser,$dbpass,$dbname);
	unset($dbhost,$dbuser,$dbpass,$dbname);
	
	$jobarr=$_SESSION['hkjob'];
	foreach($jobarr as $job){
		$jobids[]=$job['jobid'];
	}
	$smarty->assign('jobids',$jobids);
	require_once(QISHI_ROOT_PATH.'include/fun_category.php');
	require_once(QISHI_ROOT_PATH.'include/fun_jobs.php');
	$smarty->display('jobs-compare.htm',$qs_cached_dir);
	
}
?>
